/* 
 * @moduleName: TransFormUploadeUtil.js
 * @Desc: 辅助函数 防止后期antd更新Uploade的类型过多 造成单文件逻辑复杂 进行二次抽离
 * @Author: djkloop 
 * @Date: 2017-12-15 13:30:20 
 * @Last Modified by: djkloop
 * @Last Modified time: 2017-12-21 00:33:56
 */

import React from 'react';
import Uploader from '../../../common/Uploader/Uploader'
import colUtil from './ColWrapperUtil'

export default {
  transformUploader(field,type) {
    let _rules = field.dateRules && type === 'single' ? field.dateRules.rules : [];
    return colUtil.colWrapper((getFieldDecorator, forUpdate) => getFieldDecorator(field.key, {
      initialValue: forUpdate ? undefined : field.defaultValue,
      rules: _rules,
    })(
      <Uploader btnText={field.btnText} btnIcon={field.btnIcon} name={field.name} max={field.max} url={field.url} sizeLimit={field.sizeLimit} accept={field.accept}
                    placeholder={field.placeholder} type={field.type}/>
    ), field);
  }
}